<template>
    <div>
        <Meta-Dialog v-model="isShow">
            <template #header><div>规则重置提醒</div> </template>

            <div class="leading-[20px] text-center py-[24px]">
                <div class="text-[16px] text-color333 mb-[10px]">
                    规则全部重置？
                </div>
                <div class="text-[14px] text-color333/55">
                    规则重置后，当前修改的体检结论将被全部清空
                </div>
            </div>

            <div class="flex justify-center mt-[10px] mb-[5px] px-[7px]">
                <el-button size="small" @click="close">取消</el-button>
                <el-button
                    type="danger"
                    size="small"
                    @click="doSave"
                    :loading="saveLoading"
                    >重置</el-button
                >
            </div>
        </Meta-Dialog>
    </div>
</template>

<script setup>
import { ResetItemDataAsyncApi } from '@/api/home'
import { inject, ref } from 'vue'

const isShow = ref(false)
const saveLoading = ref(false)
const zhinengtijianData = inject('zhinengtijianData')
const getZhiJjianDetail = inject('getZhiJjianDetail')

const open = () => {
    isShow.value = true
}

const close = () => {
    isShow.value = false
}

const doSave = () => {
    saveLoading.value = true
    ResetItemDataAsyncApi({
        knowledgeID: zhinengtijianData.value.KnowledgeID
    })
        .then((res) => {
            saveLoading.value = false
            if (res?.Code == '200') {
                ElMessage.success('重置成功')
                close()
                getZhiJjianDetail()
            } else {
                ElMessage.error(res.Message)
            }
        })
        .catch((e) => {
            console.log(e)
            saveLoading.value = false
        })
}

defineExpose({
    open
})
</script>

<style scoped lang="scss"></style>
